home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / strlib.zip / STRNTRAN.C < prev    next >
Text File  |  1993-01-04  |  1KB  |  48 lines

  1.  
  2. /*  File   : strntrans.c
  3.     Author : Richard A. O'Keefe.
  4.     Updated: 2 June 1984
  5.     Defines: strntrans()
  6.  
  7.     strntrans(dst, src, len, from, to)
  8.     Moves characters from src to dst, translating characters in from[]
  9.     to the corresponding characters in to[], until either len characters
  10.     have been moved or a NUL has been moved.  If fewer than len characters
  11.     are moved, the remainder of dst will be filled with NULs, much like
  12.     strncpy and family.  No value is returned.
  13.  
  14.     Apology: in the previous distribution of this package, strntrans was
  15.     defined the way memtrans is now defined.  This is more consistent with
  16.     the general naming conventions.
  17. */
  18.  
  19. #include "strings.h"
  20. #include "_str2map.h"
  21.  
  22. #if     VaxAsm
  23.  
  24. void strntrans(dst, src, len, from, to)
  25.     _char_ *dst, *src, *from, *to;
  26.     int len;
  27.     {
  28.         _str2map(0, from, to);
  29.         asm("movtuc 20(ap),*8(ap),$0,__map_vec,20(ap),*4(ap)");
  30.         /* now pad the destination out with NUL characters */
  31.         asm("movc5 $0,*8(ap),$0,r4,(r5)");
  32.     }
  33.  
  34. #else  ~VaxAsm
  35.  
  36. void strntrans(dst, src, len, from, to)
  37.     register _char_ *dst, *src;
  38.     register int len;
  39.     _char_ *from, *to;
  40.     {
  41.         _str2map(0, from, to);
  42.         while (--len >= 0 && (*dst++ = _map_vec[*src++])) ;
  43.         while (--len >= 0) *dst++ = NUL;
  44.     }
  45.  
  46. #endif  VaxAsm
  47.  
  48.